SpecialCharactersEmoji   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A init 0 6 1
A getEmojis 0 9 2
1
/*
2
 * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
3
 *
4
 *  Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
5
 *
6
 *  This program is free software: you can redistribute it and/or modify
7
 *  it under the terms of the GNU Affero General Public License as published
8
 *  by the Free Software Foundation, either version 3 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU Affero General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU Affero General Public License
17
 *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
import SpecialCharacters from '@ckeditor/ckeditor5-special-characters/src/specialcharacters';
21
import SpecialCharactersEssentials from '@ckeditor/ckeditor5-special-characters/src/specialcharactersessentials';
22
23
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
24
25
const emoji = require('emoji.json');
26
27
export default class SpecialCharactersEmoji extends Plugin {
28
29
    init() {
30
        const editor = this.editor;
31
        const specialCharsPlugin = editor.plugins.get('SpecialCharacters');
32
33
        specialCharsPlugin.addItems('Emoji', this.getEmojis());
34
    }
35
36
    getEmojis() {
37
        //Map our emoji data to the format the plugin expects
38
        return emoji.map(emoji => {
39
            return {
40
                title: emoji.name,
41
                character: emoji.char
42
            };
43
        });
44
    }
45
}